package com.mak.selective.processor;

import javax.script.ScriptEngineManager;

import com.mak.selective.exception.FormulaProcessingException;


public final class FormulaProcessor implements IProcessor{

    @SuppressWarnings("restriction")
	public Object process(final String formula)throws FormulaProcessingException 
    {
        try {
			ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        	return scriptEngineManager.getEngineByName("JavaScript").eval(formula);
        } catch (Exception e) {
            throw new FormulaProcessingException("Unable to process the formula " + formula);
        }
    }
}